var BackofficePermissionDetail = {
	 
	load : function () {
		var qs =  new QueryString();
		var account =qs.get("account");
		this.setData(account);
		this.eventReister();
		Ext.getDom("userName").innerHTML =  getUser().Name;	
	},
	
	eventReister : function () {
		  Ext.get("btnNext").on('click',this.next);  //確認,新增使用者	
	},
	
	next : function () {
		/* 
		if (!Ext.get("account").getValue()){
	    	alert("請輸入[帳號]!");
	    	Ext.get("account").focus();
	    	return;
	    }
		
		if (!Ext.get("account").getValue().isEmail()){
	    	alert("[帳號]非正確Email格式!");
	    	Ext.get("account").focus();
	    	return;
	    }*/
	  
	    if (!Ext.get("password").getValue()) {
	    	alert("請輸入[密碼]!");
	    	Ext.get("password").focus();
	    	return ;
	    }
	    
	    if (!confirm("確認修改?"))return false;
	    
	    waitShow("修改中...");
	    Ext.Ajax.request({
	    	url : "/ad/sys/com/control/UserService.php?action=modifyUser",
	    	method : "POST",
            params :{
            	account : Ext.get("account").getValue(),
            	password : Ext.get("password").getValue(),
            	status : getRedioValue("status")
            },     
	    	callback : function (options, se, rsp) {
	    		
	    		waitHide();
	    		 
	    		var obj =  rsp.responseText.toJSON();  
	    		 
	    		if (obj.result =="1") {
	    			alert("修改成功!");
	    		} else{
	    			alert("修改失敗!");
	    		}
	    	}
	    	
	    })
	},
	
	setData : function (account) {
		var mask = createMask();
		mask.show();
		Ext.Ajax.request({
			url : "/ad/sys/com/control/UserService.php?action=getUserNotStatus&account="+account,
			callback : function (op, sc, resp) {
				mask.hide();
				var obj =  resp.responseText.toJSON();	
			    Ext.getDom("account").value =  obj.Account;
			    Ext.getDom("password").value =  obj.Password;
			    Ext.getDom("name").value =  obj.Name;
			    Ext.getDom("createTime").value =  obj.CreateTime.toDateString();
			    
			   var status =  document.getElementsByName("status");
			   if (obj.Status == "0"){
			   		status[1].checked = true;
			   } else {
			   		status[0].checked = true;
			   }
			   
			   
			}
		}); 
	}
}

Ext.onReady(function (){
	BackofficePermissionDetail.load();
});